Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Node.js how to take a class method argument and use it to call "this.argument"

hey guys i have a question. So i have a class in nodejs and in the constructor i initialiuse a few smart contracts from uniswap. However i am making a function that takes in as a parameter on one the smart contratcs that i initialise in the constructor. however when I i try to call the method and pass in the uniswapFactoryContract as an arg called "echangeName", node takes this.exchangeName asit is, but instead of taking exchangeName as the arg i pass in it takes it as this.echangeName not this.TheNameOfTheArgIPassIn. My code is below could anyone help me or provide another way

module.exports =class Registry {

constructor() {

    //default token addresses
    this.DAI = "0x6b175474e89094c44da98b954eedeac495271d0f";
    this.WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";

    //default provided exhange addressses
    this.UniswapFactoryAddress = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
    this.UniswapRouterAddress = "0xf164fC0Ec4E93095b804a4795bBe1e041497b92a";

    

}

//when i call this in index.js i specifcy the uniswapFactoryaddress as the exchange name paramrer
async getTokenPairSddress(addressToken0, addressToken1,  exchangeName) {

   
    //this line throws the error it thinks i want this.echange name instead of
    //this.uniswapFactoryContract
    const pairAddress = await this.exchangeName.methods.getPair(addressToken0, addressToken1).call();

    return pairAddress;

}

}

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda